package com.serviceImpl;

import com.domain.Document;
import com.dao.DocumentDao;
import com.server.DocumentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Date;

@Service("documentService")
public class DocumentServiceImpl implements DocumentService{

    @Resource(name="documentDao")
    private DocumentDao documentDao;

    //显示所有附件信息
    public List showDocument(int space_id){
        return documentDao.showDocument(space_id);
    }

    //分页显示
    public List<Document> findAllFileByPage(int space_id,int page,int pageSize){
        int from=(page-1)*pageSize;
        return documentDao.findAllFileByPage(space_id,from,pageSize);
    }

    //根据资源id显示附件信息
    public List showDocumentByResourceId(Integer id){
        return documentDao.showDocumentByResourceId(id);
    }

    //新建文件信息
    public Integer insertDocument(String filename,double filesize,Date createdate,
                                   Integer downloadcount,Integer member_id,Integer resource_id,Integer contribute_id,Integer space_id){
        return documentDao.insertDocument(filename,filesize,createdate,downloadcount,member_id,resource_id,contribute_id,space_id);
    }

    //根据id删除附件
    public Integer deleteFile(Integer id){
        return documentDao.deleteFile(id);
    }

    //修改下载次数
    public Integer updateNum(Integer id,Integer downloadcount){
        return documentDao.updateNum(id,downloadcount);
    }

    @Override
    public List<Document> showDocumentById(Integer id) {
        return documentDao.showDocumentById(id);
    }
}
